package com.ncp.servlet.product;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ncp.model.biz.product.ManageBackstageProductBiz;
import com.ncp.model.entity.product.ProductSortBean;

public class ManagerSortServlet extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		boolean b = false;
		String sortname = request.getParameter("sortname");
		
		
		
		if(sortname==""){
			request.getRequestDispatcher("pages/product/admin/warn.jsp").forward(request,response);

		}
		else{
			
			
		ProductSortBean psb = new ProductSortBean();
		
		psb.setProductSortName(sortname);
		psb.setParentProductSortID(0);
		psb.setRootProductSortID(0);
		psb.setIsover(0);
		
		ManageBackstageProductBiz mbp = new ManageBackstageProductBiz();
		b = mbp.setSortInfo(psb);
		if(b==true){
			
			String pages="ManagerShowSortServlet";
			request.setAttribute("pages",pages);
			request.getRequestDispatcher("pages/admin/product/suc.jsp").forward(request,response);
			
		}else{
			
			request.getRequestDispatcher("pages/admin/product/err.jsp").forward(request,response);
		}
		
		}
	}

}
